﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common;
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Entities.Modules;
    using DotNetNuke.Entities.Portals;
    using DotNetNuke.Entities.Users;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Runtime.CompilerServices;
    using System.Web.UI.WebControls;
    using System.Xml;

    public class AdminHost : BaseAdminModule
    {
        [AccessedThroughProperty("cmdCalcSale")]
        private LinkButton _cmdCalcSale;
        [AccessedThroughProperty("cmdClearSettings")]
        private LinkButton _cmdClearSettings;
        [AccessedThroughProperty("cmdClearStore")]
        private LinkButton _cmdClearStore;
        [AccessedThroughProperty("cmdClearTempUpload")]
        private LinkButton _cmdClearTempUpload;
        [AccessedThroughProperty("cmdCreateThumbs")]
        private LinkButton _cmdCreateThumbs;
        [AccessedThroughProperty("cmdExportReport")]
        private LinkButton _cmdExportReport;
        [AccessedThroughProperty("cmdImportDefault")]
        private LinkButton _cmdImportDefault;
        [AccessedThroughProperty("cmdImportReports")]
        private LinkButton _cmdImportReports;
        [AccessedThroughProperty("cmdPurgeFiles")]
        private LinkButton _cmdPurgeFiles;
        [AccessedThroughProperty("cmdRestart")]
        private LinkButton _cmdRestart;
        [AccessedThroughProperty("cmdSaveSettings")]
        private LinkButton _cmdSaveSettings;
        [AccessedThroughProperty("cmdUpgradeAll")]
        private LinkButton _cmdUpgradeAll;
        [AccessedThroughProperty("cmdValidation")]
        private LinkButton _cmdValidation;
        [AccessedThroughProperty("chkLlang")]
        private CheckBoxList _chkLlang;
        [AccessedThroughProperty("chkLsettings")]
        private CheckBoxList _chkLsettings;
        [AccessedThroughProperty("chkLtemplates")]
        private CheckBoxList _chkLtemplates;
        [AccessedThroughProperty("chkOverwriteReport")]
        private CheckBox _chkOverwriteReport;
        [AccessedThroughProperty("chkOverwriteSettings")]
        private CheckBox _chkOverwriteSettings;
        [AccessedThroughProperty("chkSelectAll")]
        private CheckBox _chkSelectAll;
        [AccessedThroughProperty("chkSelectAllT")]
        private CheckBox _chkSelectAllT;
        [AccessedThroughProperty("chkValidation")]
        private CheckBox _chkValidation;
        [AccessedThroughProperty("dgPortals")]
        private DataGrid _dgPortals;
        private bool _DoUpgrade;
        [AccessedThroughProperty("fupReports")]
        private FileUpload _fupReports;
        [AccessedThroughProperty("fupTemplate")]
        private FileUpload _fupTemplate;
        [AccessedThroughProperty("lblchkSettings")]
        private Label _lblchkSettings;
        [AccessedThroughProperty("lblGeneral")]
        private Label _lblGeneral;
        [AccessedThroughProperty("lblInvalidPass")]
        private Label _lblInvalidPass;
        [AccessedThroughProperty("lblLang")]
        private Label _lblLang;
        [AccessedThroughProperty("lblReports")]
        private Label _lblReports;
        [AccessedThroughProperty("lblSettings")]
        private Label _lblSettings;
        [AccessedThroughProperty("lblTemplates")]
        private Label _lblTemplates;
        [AccessedThroughProperty("lblValidationMsg")]
        private Label _lblValidationMsg;
        [AccessedThroughProperty("PlaceHolder1")]
        private PlaceHolder _PlaceHolder1;
        [AccessedThroughProperty("pnlCheckBoxLists")]
        private Panel _pnlCheckBoxLists;
        [AccessedThroughProperty("pnlHost")]
        private Panel _pnlHost;
        private bool _ShowUpgrade;
        [AccessedThroughProperty("txtPass")]
        private TextBox _txtPass;

        public AdminHost()
        {
            base.Load += new EventHandler(this.Page_Load);
            this._ShowUpgrade = false;
            this._DoUpgrade = false;
        }

        private void cmdCalcSale_Click(object sender, EventArgs e)
        {
            new PromoController().createSalePriceTable(this.PortalId, -1);
        }

        private void cmdClearSettings_Click(object sender, EventArgs e)
        {
            IEnumerator enumerator=null;
            IEnumerator enumerator2=null;
            SettingsController controller = new SettingsController();
            Upgrade upgrade = new Upgrade();
            ArrayList list = controller.GetSettingList(this.PortalId, "", true, "");
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    NB_Store_SettingsInfo current = (NB_Store_SettingsInfo) enumerator.Current;
                    controller.DeleteSetting(this.PortalId, current.SettingName, current.Lang);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            list = controller.GetSettingsTexts(this.PortalId, "", true, "");
            try
            {
                enumerator2 = list.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    NB_Store_SettingsTextInfo info2 = (NB_Store_SettingsTextInfo) enumerator2.Current;
                    controller.DeleteSettingsText(this.PortalId, info2.SettingName, info2.Lang);
                }
            }
            finally
            {
                if (enumerator2 is IDisposable)
                {
                    (enumerator2 as IDisposable).Dispose();
                }
            }
            SharedFunctions.removeLangCache(this.PortalId, "nbstoreadmintemplatetreemenu" + this.UserId.ToString());
            SharedFunctions.removeLangCache(this.PortalId, "nbstoreadminsettingtreemenu" + this.UserId.ToString());
            upgrade.DoUpgrade(this.PortalId, base.StoreInstallPath, this.UserId);
        }

        private void cmdClearStore_Click(object sender, EventArgs e)
        {
            var userInfo = this.UserInfo;
            if (this.txtPass.Text == UserController.GetPassword(ref userInfo, ""))
            {
                this.lblInvalidPass.Visible = false;
                DataProvider.Instance().ClearDownStore(this.PortalId);
            }
            else
            {
                this.lblInvalidPass.Visible = true;
            }
        }

        private void cmdClearTempUpload_Click(object sender, EventArgs e)
        {
            SharedFunctions.RemoveFiles(this.PortalSettings, "temp");
        }

        private void cmdCreateThumbs_Click(object sender, EventArgs e)
        {
            if (SharedFunctions.GetStoreSettingBoolean(this.PortalId, "diskthumbnails.flag"))
            {
                string storeSetting = SharedFunctions.GetStoreSetting(this.PortalId, "diskthumbnails.size");
                if (storeSetting != "")
                {
                    ThumbFunctions functions = new ThumbFunctions();
                    SharedFunctions.CreateDir(this.PortalSettings, "productthumbs");
                    if (Versioned.IsNumeric(SharedFunctions.GetStoreSetting(this.PortalId, "image.quality")))
                    {
                        functions._ImageQuality = Conversions.ToInteger(SharedFunctions.GetStoreSetting(this.PortalId, "image.quality"));
                    }
                    functions.CreateAllThumbsOnDisk(this.PortalId, SharedFunctions.GetCurrentCulture(), storeSetting);
                }
            }
        }

        private void cmdExportReport_Click(object sender, EventArgs e)
        {
            string fileData = "";
            PortalSettings currentPortalSettings = PortalController.GetCurrentPortalSettings();
            Export export = new Export();
            fileData = ("<content type=\"" + this.ModuleConfiguration.DesktopModule.ModuleName + "\" version=\"" + this.ModuleConfiguration.DesktopModule.Version + "\">") + export.GetSQLReports(currentPortalSettings.PortalId) + "</content>";
            SharedFunctions.ForceStringDownload(this.Response, "NB_Store_ExportReports.xml", fileData);
        }

        private void cmdImportDefault_Click(object sender, EventArgs e)
        {
            if (this.pnlCheckBoxLists.Visible)
            {
                this.DoDefaultImport("ImportedSettings.xml");
                SharedFunctions.removeLangCache(this.PortalId, "nbstoreadmintemplatetreemenu" + this.UserId.ToString());
                SharedFunctions.removeLangCache(this.PortalId, "nbstoreadminsettingtreemenu" + this.UserId.ToString());
                this.Response.Redirect(this.EditUrl("AdminHost"), true);
            }
            else if (this.fupTemplate.FileName != "")
            {
                this.fupTemplate.SaveAs(this.Server.MapPath(base.StoreInstallPath + @"templates\ImportedSettings.xml"));
                if (this.chkOverwriteSettings.Checked)
                {
                    SharedFunctions.SetStoreSetting(this.PortalId, "settings.overwrite", Conversions.ToString(1), "None", true);
                }
                else
                {
                    SharedFunctions.SetStoreSetting(this.PortalId, "settings.overwrite", Conversions.ToString(0), "None", true);
                }
                this.populateImportCheckBox("ImportedSettings.xml");
            }
        }

        private void cmdImportReports_Click(object sender, EventArgs e)
        {
            if (this.fupReports.FileName != "")
            {
                this.fupReports.SaveAs(this.Server.MapPath(base.StoreInstallPath + @"templates\ImportedReports.xml"));
                new Import().ImportSQLReports(this.PortalId, this.Server.MapPath(base.StoreInstallPath + @"templates\ImportedReports.xml"), this.chkOverwriteReport.Checked);
            }
        }

        private void cmdPurgeFiles_Click(object sender, EventArgs e)
        {
            SharedFunctions.PurgeAllFiles(this.PortalSettings);
        }

        private void cmdRestart_Click(object sender, EventArgs e)
        {
            object instance = new Config();
            NewLateBinding.LateCall(instance, null, "Touch", new object[0], null, null, null, true);
            this.Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
        }

        private void cmdSaveSettings_Click(object sender, EventArgs e)
        {
            if (this.pnlCheckBoxLists.Visible)
            {
                ManagerMenuController controller = new ManagerMenuController();
                string fileData = "";
                fileData = ("<content type=\"" + this.ModuleConfiguration.DesktopModule.ModuleName + "\" version=\"" + this.ModuleConfiguration.DesktopModule.Version + "\">") + controller.ExportModuleData(this.ModuleId, this.chkLsettings, this.chkLtemplates, this.chkLlang, false, false) + "</content>";
                SharedFunctions.ForceStringDownload(this.Response, "NB_Store_ExportSettings.xml", fileData);
            }
            else
            {
                this.populateExportCheckBox();
            }
        }

        private void cmdUpgradeAll_Click(object sender, EventArgs e)
        {
            this._DoUpgrade = true;
            this.PopulatePortalList();
        }

        private void cmdValidation_Click(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();
            string str = "";
            SharedFunctions.CreateDir(this.PortalSettings, "productdocs");
            SharedFunctions.CreateDir(this.PortalSettings, "productimages");
            SharedFunctions.CreateDir(this.PortalSettings, "productthumbs");
            FileSystemUtils.SynchronizeFolder(this.PortalId, this.PortalSettings.HomeDirectoryMapPath + "productdocs", this.PortalSettings.HomeDirectory + "productdocs", true, true, true);
            FileSystemUtils.SynchronizeFolder(this.PortalId, this.PortalSettings.HomeDirectoryMapPath + "productimages", this.PortalSettings.HomeDirectory + "productimages", true, true, true);
            FileSystemUtils.SynchronizeFolder(this.PortalId, this.PortalSettings.HomeDirectoryMapPath + "productthumbs", this.PortalSettings.HomeDirectory + "productthumbs", true, true, true);
            str = "<br /><br />Product Images: ";
            str = (str + controller.ImageValidation(this.PortalId, this.MapPath(@"\"), this.chkValidation.Checked)) + "<br />Product Docs: " + controller.DocValidation(this.PortalId, this.PortalSettings.HomeDirectoryMapPath + "productdocs", this.chkValidation.Checked);
            if (this.chkValidation.Checked)
            {
                str = (str + "<br />Product Languages: " + controller.ProductLangValidation(this.PortalId)) + "<br />Category Languages: " + controller.CategoryLangValidation(this.PortalId);
            }
            else
            {
                str = str + "<br />Product Languages: NOT CHECKED" + "<br />Category Languages: NOT CHECKED";
            }
            if (str != "")
            {
                this.lblValidationMsg.Text = str;
                this.lblValidationMsg.Visible = true;
            }
        }

        private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            if (this.cmdImportDefault.Visible)
            {
                this.populateImportCheckBox("ImportedSettings.xml");
            }
            else
            {
                this.populateExportCheckBox();
            }
        }

        private void dgPortals_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;
            if (((item.ItemType == ListItemType.Item) | (item.ItemType == ListItemType.AlternatingItem)) | (item.ItemType == ListItemType.SelectedItem))
            {
                Upgrade upgrade = new Upgrade();
                int portalID = Conversions.ToInteger(item.Cells[0].Text);
                if (item.Cells[2].Text != upgrade.getCurrentStoreVersion(base.StoreInstallPath))
                {
                    this._ShowUpgrade = true;
                }
                if (this._DoUpgrade)
                {
                    Label label = (Label) e.Item.FindControl("lblMsg");
                    if (upgrade.DoUpgrade(portalID, base.StoreInstallPath, this.UserId) == "")
                    {
                        label.Text = DotNetNuke.Services.Localization.Localization.GetString("UpgradeOK", this.LocalResourceFile);
                    }
                    else
                    {
                        label.Text = DotNetNuke.Services.Localization.Localization.GetString("UpgradeFAIL", this.LocalResourceFile);
                    }
                    item.Cells[2].Text = SharedFunctions.GetStoreSetting(portalID, "version", "None");
                }
            }
        }

        private void DoDefaultImport(string ImpFileName)
        {
            XmlDataDocument document = new XmlDataDocument();
            ManagerMenuController controller = new ManagerMenuController();
            if (ImpFileName != "")
            {
                document.Load(this.Server.MapPath(base.StoreInstallPath + @"templates\" + ImpFileName));
                controller.ImportModuleData(this.ModuleId, document.SelectSingleNode("content").InnerXml, "1", this.UserId, this.chkLsettings, this.chkLtemplates, this.chkLlang);
            }
            new Upgrade().setStoreVersionToCurrent(this.PortalId, base.StoreInstallPath);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SharedFunctions.DisplayMsgText(Conversions.ToString(this.PortalId), this.PlaceHolder1, "adminhost.text", "");
                if (this.UserInfo.IsSuperUser | this.UserInfo.IsInRole("Administrators"))
                {
                    bool flag = false;
                    if (!this.Page.IsPostBack)
                    {
                        this.pnlCheckBoxLists.Visible = false;
                        flag = SharedFunctions.GetStoreSettingBoolean(this.PortalId, "settings.overwrite", "None");
                        this.chkOverwriteSettings.Checked = flag;
                        this.PopulatePortalList();
                    }
                    if (this._ShowUpgrade)
                    {
                        this.cmdUpgradeAll.Visible = true;
                    }
                    else
                    {
                        this.cmdUpgradeAll.Visible = false;
                    }
                    this.cmdClearStore.Attributes.Add("onClick", "javascript:return confirm('" + DotNetNuke.Services.Localization.Localization.GetString("cmdClearStoreMsg", this.LocalResourceFile) + "');");
                    this.cmdImportDefault.Attributes.Add("onClick", "javascript:return confirm('" + DotNetNuke.Services.Localization.Localization.GetString("cmdImportDefaultMsg", this.LocalResourceFile) + "');");
                    this.cmdClearSettings.Attributes.Add("onClick", "javascript:return confirm('" + DotNetNuke.Services.Localization.Localization.GetString("cmdClearSettingsMsg", this.LocalResourceFile) + "');");
                    this.cmdCreateThumbs.Attributes.Add("onClick", "javascript:return confirm('" + DotNetNuke.Services.Localization.Localization.GetString("cmdCreateThumbsMsg", this.LocalResourceFile) + "');");
                    this.cmdPurgeFiles.Attributes.Add("onClick", "javascript:return confirm('" + DotNetNuke.Services.Localization.Localization.GetString("cmdPurgeFilesMsg", this.LocalResourceFile) + "');");
                    this.pnlHost.Visible = true;
                }
                else
                {
                    this.pnlHost.Visible = false;
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                ProjectData.ClearProjectError();
            }
        }

        private void populateExportCheckBox()
        {
            IEnumerator enumerator=null;
            IEnumerator enumerator2=null;
            IEnumerator enumerator3=null;
            SettingsController controller = new SettingsController();
            LocaleCollection validLocales = SharedFunctions.GetValidLocales();
            this.pnlCheckBoxLists.Visible = true;
            this.lblLang.Text = DotNetNuke.Services.Localization.Localization.GetString("lblLang", this.LocalResourceFile);
            this.lblchkSettings.Text = DotNetNuke.Services.Localization.Localization.GetString("lblchkSettings", this.LocalResourceFile);
            this.lblTemplates.Text = DotNetNuke.Services.Localization.Localization.GetString("lblTemplates", this.LocalResourceFile);
            this.chkSelectAll.Text = DotNetNuke.Services.Localization.Localization.GetString("chkSelectAll", this.LocalResourceFile);
            this.chkSelectAllT.Text = DotNetNuke.Services.Localization.Localization.GetString("chkSelectAll", this.LocalResourceFile);
            this.cmdImportDefault.Visible = false;
            this.fupTemplate.Visible = false;
            this.chkOverwriteSettings.Visible = false;
            this.cmdClearSettings.Visible = false;
            this.dgPortals.Visible = false;
            this.chkLlang.Items.Clear();
            ListItem item = new ListItem {
                Text = DotNetNuke.Services.Localization.Localization.GetString("Default", this.LocalResourceFile),
                Value = "None",
                Selected = true
            };
            this.chkLlang.Items.Add(item);
            try
            {
                enumerator = validLocales.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string str = Conversions.ToString(enumerator.Current);
                    item = new ListItem {
                        Text = str,
                        Value = str,
                        Selected = true
                    };
                    this.chkLlang.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            this.chkLsettings.Items.Clear();
            ArrayList list = controller.GetSettingList(this.PortalId, "", true, "");
            try
            {
                enumerator2 = list.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    NB_Store_SettingsInfo current = (NB_Store_SettingsInfo) enumerator2.Current;
                    item = new ListItem();
                    if (current.Lang.Trim() != "None")
                    {
                        item.Text = current.SettingName + " : " + current.Lang.Trim();
                    }
                    else
                    {
                        item.Text = current.SettingName;
                    }
                    item.Value = current.SettingName;
                    item.Selected = this.chkSelectAll.Checked;
                    this.chkLsettings.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator2 is IDisposable)
                {
                    (enumerator2 as IDisposable).Dispose();
                }
            }
            this.chkLtemplates.Items.Clear();
            list = controller.GetSettingsTexts(this.PortalId, "", true, "");
            try
            {
                enumerator3 = list.GetEnumerator();
                while (enumerator3.MoveNext())
                {
                    NB_Store_SettingsTextInfo info2 = (NB_Store_SettingsTextInfo) enumerator3.Current;
                    item = new ListItem();
                    if (info2.Lang.Trim() != "None")
                    {
                        item.Text = info2.SettingName + " : " + info2.Lang.Trim();
                    }
                    else
                    {
                        item.Text = info2.SettingName;
                    }
                    item.Value = info2.SettingName;
                    item.Selected = this.chkSelectAllT.Checked;
                    this.chkLtemplates.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator3 is IDisposable)
                {
                    (enumerator3 as IDisposable).Dispose();
                }
            }
        }

        private void populateImportCheckBox(string ImpFileName)
        {
            XmlNode current;
            IEnumerator enumerator=null;
            IEnumerator enumerator2=null;
            IEnumerator enumerator3=null;
            SettingsController controller2 = new SettingsController();
            LocaleCollection validLocales = SharedFunctions.GetValidLocales();
            XmlDataDocument document = new XmlDataDocument();
            ManagerMenuController controller = new ManagerMenuController();
            if (ImpFileName != "")
            {
                document.Load(this.Server.MapPath(base.StoreInstallPath + @"templates\" + ImpFileName));
            }
            this.pnlCheckBoxLists.Visible = true;
            this.lblLang.Text = DotNetNuke.Services.Localization.Localization.GetString("lblLang", this.LocalResourceFile);
            this.lblchkSettings.Text = DotNetNuke.Services.Localization.Localization.GetString("lblchkSettings", this.LocalResourceFile);
            this.lblTemplates.Text = DotNetNuke.Services.Localization.Localization.GetString("lblTemplates", this.LocalResourceFile);
            this.chkSelectAll.Text = DotNetNuke.Services.Localization.Localization.GetString("chkSelectAll", this.LocalResourceFile);
            this.chkSelectAllT.Text = DotNetNuke.Services.Localization.Localization.GetString("chkSelectAll", this.LocalResourceFile);
            this.cmdSaveSettings.Visible = false;
            this.fupTemplate.Visible = false;
            this.chkOverwriteSettings.Enabled = false;
            this.cmdClearSettings.Visible = false;
            this.dgPortals.Visible = false;
            this.chkLlang.Items.Clear();
            ListItem item = new ListItem {
                Text = DotNetNuke.Services.Localization.Localization.GetString("Default", this.LocalResourceFile),
                Value = "None",
                Selected = true
            };
            this.chkLlang.Items.Add(item);
            try
            {
                enumerator = validLocales.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    string str = Conversions.ToString(enumerator.Current);
                    item = new ListItem {
                        Text = str,
                        Value = str,
                        Selected = true
                    };
                    this.chkLlang.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            this.chkLsettings.Items.Clear();
            XmlNodeList list = document.SelectNodes("content/storecontent/settings/*");
            try
            {
                enumerator2 = list.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    current = (XmlNode) enumerator2.Current;
                    item = new ListItem();
                    if (Strings.Trim(current.Attributes["Lang"].InnerXml) != "None")
                    {
                        item.Text = current.Name + current.Attributes["Lang"].InnerXml;
                    }
                    else
                    {
                        item.Text = current.Name;
                    }
                    item.Value = current.Name;
                    item.Selected = this.chkSelectAll.Checked;
                    this.chkLsettings.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator2 is IDisposable)
                {
                    (enumerator2 as IDisposable).Dispose();
                }
            }
            this.chkLtemplates.Items.Clear();
            list = document.SelectNodes("content/storecontent/settingstext/*");
            try
            {
                enumerator3 = list.GetEnumerator();
                while (enumerator3.MoveNext())
                {
                    current = (XmlNode) enumerator3.Current;
                    item = new ListItem();
                    if (Strings.Trim(current.Attributes["Lang"].InnerXml) != "None")
                    {
                        item.Text = current.Name + " : " + current.Attributes["Lang"].InnerXml;
                    }
                    else
                    {
                        item.Text = current.Name;
                    }
                    item.Value = current.Name;
                    item.Selected = this.chkSelectAllT.Checked;
                    this.chkLtemplates.Items.Add(item);
                }
            }
            finally
            {
                if (enumerator3 is IDisposable)
                {
                    (enumerator3 as IDisposable).Dispose();
                }
            }
        }

        private void PopulatePortalList()
        {
            if (this.UserInfo.IsSuperUser)
            {
                IEnumerator enumerator=null;
                ArrayList list = new ArrayList();
                ArrayList portals = new PortalController().GetPortals();
                try
                {
                    enumerator = portals.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        PortalInfo current = (PortalInfo) enumerator.Current;
                        string str = SharedFunctions.GetStoreSetting(current.PortalID, "version", "None");
                        if (str != "")
                        {
                            current.Version = str;
                            list.Add(current);
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                this.dgPortals.Visible = true;
                this.dgPortals.DataSource = list;
                this.dgPortals.DataBind();
            }
            else
            {
                this.dgPortals.Visible = false;
            }
        }

        protected virtual LinkButton cmdCalcSale
        {
            get
            {
                return this._cmdCalcSale;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdCalcSale_Click);
                if (this._cmdCalcSale != null)
                {
                    this._cmdCalcSale.Click -= handler;
                }
                this._cmdCalcSale = value;
                if (this._cmdCalcSale != null)
                {
                    this._cmdCalcSale.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdClearSettings
        {
            get
            {
                return this._cmdClearSettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdClearSettings_Click);
                if (this._cmdClearSettings != null)
                {
                    this._cmdClearSettings.Click -= handler;
                }
                this._cmdClearSettings = value;
                if (this._cmdClearSettings != null)
                {
                    this._cmdClearSettings.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdClearStore
        {
            get
            {
                return this._cmdClearStore;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdClearStore_Click);
                if (this._cmdClearStore != null)
                {
                    this._cmdClearStore.Click -= handler;
                }
                this._cmdClearStore = value;
                if (this._cmdClearStore != null)
                {
                    this._cmdClearStore.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdClearTempUpload
        {
            get
            {
                return this._cmdClearTempUpload;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdClearTempUpload_Click);
                if (this._cmdClearTempUpload != null)
                {
                    this._cmdClearTempUpload.Click -= handler;
                }
                this._cmdClearTempUpload = value;
                if (this._cmdClearTempUpload != null)
                {
                    this._cmdClearTempUpload.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdCreateThumbs
        {
            get
            {
                return this._cmdCreateThumbs;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdCreateThumbs_Click);
                if (this._cmdCreateThumbs != null)
                {
                    this._cmdCreateThumbs.Click -= handler;
                }
                this._cmdCreateThumbs = value;
                if (this._cmdCreateThumbs != null)
                {
                    this._cmdCreateThumbs.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdExportReport
        {
            get
            {
                return this._cmdExportReport;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdExportReport_Click);
                if (this._cmdExportReport != null)
                {
                    this._cmdExportReport.Click -= handler;
                }
                this._cmdExportReport = value;
                if (this._cmdExportReport != null)
                {
                    this._cmdExportReport.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdImportDefault
        {
            get
            {
                return this._cmdImportDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdImportDefault_Click);
                if (this._cmdImportDefault != null)
                {
                    this._cmdImportDefault.Click -= handler;
                }
                this._cmdImportDefault = value;
                if (this._cmdImportDefault != null)
                {
                    this._cmdImportDefault.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdImportReports
        {
            get
            {
                return this._cmdImportReports;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdImportReports_Click);
                if (this._cmdImportReports != null)
                {
                    this._cmdImportReports.Click -= handler;
                }
                this._cmdImportReports = value;
                if (this._cmdImportReports != null)
                {
                    this._cmdImportReports.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdPurgeFiles
        {
            get
            {
                return this._cmdPurgeFiles;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdPurgeFiles_Click);
                if (this._cmdPurgeFiles != null)
                {
                    this._cmdPurgeFiles.Click -= handler;
                }
                this._cmdPurgeFiles = value;
                if (this._cmdPurgeFiles != null)
                {
                    this._cmdPurgeFiles.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdRestart
        {
            get
            {
                return this._cmdRestart;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdRestart_Click);
                if (this._cmdRestart != null)
                {
                    this._cmdRestart.Click -= handler;
                }
                this._cmdRestart = value;
                if (this._cmdRestart != null)
                {
                    this._cmdRestart.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdSaveSettings
        {
            get
            {
                return this._cmdSaveSettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdSaveSettings_Click);
                if (this._cmdSaveSettings != null)
                {
                    this._cmdSaveSettings.Click -= handler;
                }
                this._cmdSaveSettings = value;
                if (this._cmdSaveSettings != null)
                {
                    this._cmdSaveSettings.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdUpgradeAll
        {
            get
            {
                return this._cmdUpgradeAll;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdUpgradeAll_Click);
                if (this._cmdUpgradeAll != null)
                {
                    this._cmdUpgradeAll.Click -= handler;
                }
                this._cmdUpgradeAll = value;
                if (this._cmdUpgradeAll != null)
                {
                    this._cmdUpgradeAll.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdValidation
        {
            get
            {
                return this._cmdValidation;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdValidation_Click);
                if (this._cmdValidation != null)
                {
                    this._cmdValidation.Click -= handler;
                }
                this._cmdValidation = value;
                if (this._cmdValidation != null)
                {
                    this._cmdValidation.Click += handler;
                }
            }
        }

        protected virtual CheckBoxList chkLlang
        {
            get
            {
                return this._chkLlang;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkLlang = value;
            }
        }

        protected virtual CheckBoxList chkLsettings
        {
            get
            {
                return this._chkLsettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkLsettings = value;
            }
        }

        protected virtual CheckBoxList chkLtemplates
        {
            get
            {
                return this._chkLtemplates;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkLtemplates = value;
            }
        }

        protected virtual CheckBox chkOverwriteReport
        {
            get
            {
                return this._chkOverwriteReport;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkOverwriteReport = value;
            }
        }

        protected virtual CheckBox chkOverwriteSettings
        {
            get
            {
                return this._chkOverwriteSettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkOverwriteSettings = value;
            }
        }

        protected virtual CheckBox chkSelectAll
        {
            get
            {
                return this._chkSelectAll;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.chkSelectAll_CheckedChanged);
                if (this._chkSelectAll != null)
                {
                    this._chkSelectAll.CheckedChanged -= handler;
                }
                this._chkSelectAll = value;
                if (this._chkSelectAll != null)
                {
                    this._chkSelectAll.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkSelectAllT
        {
            get
            {
                return this._chkSelectAllT;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.chkSelectAll_CheckedChanged);
                if (this._chkSelectAllT != null)
                {
                    this._chkSelectAllT.CheckedChanged -= handler;
                }
                this._chkSelectAllT = value;
                if (this._chkSelectAllT != null)
                {
                    this._chkSelectAllT.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkValidation
        {
            get
            {
                return this._chkValidation;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._chkValidation = value;
            }
        }

        protected virtual DataGrid dgPortals
        {
            get
            {
                return this._dgPortals;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                DataGridItemEventHandler handler = new DataGridItemEventHandler(this.dgPortals_ItemDataBound);
                if (this._dgPortals != null)
                {
                    this._dgPortals.ItemDataBound -= handler;
                }
                this._dgPortals = value;
                if (this._dgPortals != null)
                {
                    this._dgPortals.ItemDataBound += handler;
                }
            }
        }

        protected virtual FileUpload fupReports
        {
            get
            {
                return this._fupReports;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._fupReports = value;
            }
        }

        protected virtual FileUpload fupTemplate
        {
            get
            {
                return this._fupTemplate;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._fupTemplate = value;
            }
        }

        protected virtual Label lblchkSettings
        {
            get
            {
                return this._lblchkSettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblchkSettings = value;
            }
        }

        protected virtual Label lblGeneral
        {
            get
            {
                return this._lblGeneral;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblGeneral = value;
            }
        }

        protected virtual Label lblInvalidPass
        {
            get
            {
                return this._lblInvalidPass;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblInvalidPass = value;
            }
        }

        protected virtual Label lblLang
        {
            get
            {
                return this._lblLang;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblLang = value;
            }
        }

        protected virtual Label lblReports
        {
            get
            {
                return this._lblReports;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblReports = value;
            }
        }

        protected virtual Label lblSettings
        {
            get
            {
                return this._lblSettings;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblSettings = value;
            }
        }

        protected virtual Label lblTemplates
        {
            get
            {
                return this._lblTemplates;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblTemplates = value;
            }
        }

        protected virtual Label lblValidationMsg
        {
            get
            {
                return this._lblValidationMsg;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblValidationMsg = value;
            }
        }

        protected virtual PlaceHolder PlaceHolder1
        {
            get
            {
                return this._PlaceHolder1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._PlaceHolder1 = value;
            }
        }

        protected virtual Panel pnlCheckBoxLists
        {
            get
            {
                return this._pnlCheckBoxLists;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlCheckBoxLists = value;
            }
        }

        protected virtual Panel pnlHost
        {
            get
            {
                return this._pnlHost;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlHost = value;
            }
        }

        protected virtual TextBox txtPass
        {
            get
            {
                return this._txtPass;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtPass = value;
            }
        }
    }
}

